<?php


namespace app\admin\model;


class Dictionary
{
    /**
     * 任务类型字典
     * @param string $key
     * @return array
     */
    public static function taskTypeName($key = 0)
    {
        $map = [
            10 => '开发-系统设计',
            20 => '开发-代码编写',
            30 => '开发-开发联调',
            35 => '测试-编写用例',
            40 => '测试-冒烟测试',
            50 => '测试-SIT测试',
            60 => '测试-UAT测试',
            70 => '其他'
        ];
        if (array_key_exists($key, $map)) return $map[$key];
        return $map;
    }

    /**
     * 任务类型分类
     * @param string $key
     * @return array|mixed
     */
    public static function taskTypeClass($key = '')
    {
        $map = [
            'dev' => [10, 20, 30],
            'test' => [35, 40, 50, 60],
            'other' => [70],
        ];
        if (array_key_exists($key, $map)) return $map[$key];
        return $map;
    }

    /**
     * 项目优先级别
     * @return array
     */
    public static function projectLevelMap()
    {
        return [
            10 => '低',
            20 => '中',
            30 => '高'
        ];
    }

    /**
     * 任务状态
     * @return array
     */
    public static function taskStatusMap()
    {
        return [
            1 => '计划',
            10 => '进行',
            20 => '暂停',
            30 => '完成'
        ];
    }

    /**
     * 任务状态颜色
     * @return array
     */
    public static function taskStatusColorMap()
    {
        return [
            1 => 'blue',
            10 => 'green',
            20 => 'red',
            30 => 'yellow'
        ];
    }

    /**
     * 项目类型字典
     * @return array
     */
    public static function projetcTypeName()
    {
        return [
            1 => '新需求(PRD)',
            2 => '需求变更(ECR)',
            3 => '缺陷修复(BUG)'
        ];
    }

    public static function projectStageName()
    {
        return [
            10 => '待交接',
            20 => '系统设计',
            30 => '开发编码',
            40 => '开发联调',
            50 => '冒烟测试',
            60 => 'SIT测试',
            70 => 'UAT测试',
            80 => '上线'
        ];
    }

    /**项目任务状态字典
     * @return array
     */
    public static function projectStatusName()
    {
        return [
            10 => '计划',
            20 => '进行',
            30 => '暂停',
            40 => '完成'
        ];
    }

    /**
     * 项目阶段 多个系统对应
     * @param string $key
     * @param string $sys pro=>项目管理系统, jira=>jira系统
     * @return array|mixed
     */
    public static function jiraProjectStagMap($key = '', $sys = 'pro')
    {
        $map = [
            10 => [
                'pro' => '待交接',
                'jira' => '需求阶段'
            ],
            20 => [
                'pro' => '系统设计',
                'jira' => '开发阶段'
            ],
            30 => [
                'pro' => '开发编码',
                'jira' => '开发阶段'
            ],
            40 => [
                'pro' => '开发联调',
                'jira' => '开发阶段'
            ],
            50 => [
                'pro' => '冒烟测试',
                'jira' => '测试阶段'
            ],
            60 => [
                'pro' => 'SIT测试',
                'jira' => '测试阶段'
            ],
            70 => [
                'pro' => 'UAT测试',
                'jira' => '测试阶段'
            ],
            80 => [
                'pro' => '上线',
                'jira' => '已上线'
            ],
        ];

        if (array_key_exists($key, $map)) return $map[$key][$sys];


        $r = [];
        array_walk($map, function ($v, $k) use (&$r, $sys) {
            $r[$k] = $v[$sys];
        });
        return $r;
    }
}